<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<title>Media Query 3 Column App</title>
		<link type="text/css" href="../../mediaQuery3ColumnApp/css/mediaQuery3ColumnApp.css" rel="stylesheet" />
		<script type="text/javascript" src="../../../../../dojox/mobile/deviceTheme.js"></script>
		<script type="text/javascript">
			dojoConfig = {
				parseOnLoad: false,
				mblHideAddressBar: false,
				mblAndroidWorkaround: false,
                mblAlwaysHideAddressBar: false,	
				async:1,
				app: {debugApp: 0}  // set debugApp to log app transitions and view activate/deactivate
			};
		</script>
		<script type="text/javascript" src="../../../../../dojo/dojo.js"></script>

		<script>
            // the actual  launcher
            require(["../../mediaQuery3ColumnApp/mediaQuery3ColumnApp.js"], function(){});
        </script>
		<script type="text/javascript">
			require([
				"doh/runner",
				"dojo/topic",
				"dojo/_base/lang",
				"dojo/dom",
				"dojox/mobile/TransitionEvent",				
				"dijit/registry"
			], function(doh, topic, lang, dom, TransitionEvent, registry) {
				var events = [];

				var getLabelfromWid = function(wid, indx1, indx2){
					var val = wid.labelNode.innerText || wid.labelNode.firstChild.nodeValue || "";
					val = lang.trim(val);
					if(indx2){
						val = val.substring(indx1,indx2)
					}
					return val;
				};

				topic.subscribe("/app/status", lang.hitch(this, function(newStatus) {
					events.push(newStatus);
					if (newStatus == 2) {
						var listItem_0TestStr = "Main Option 1";
						var listItem_1TestStr = "Main Option 2";
						doh.register("Test-mediaQuery3ColumnApp1", [{
							// Test initial values
							name : "initial-listItem-labels",
							runTest : function() {
							var dfd = new doh.Deferred();
								setTimeout(function() {
									var ListItem_0Label = registry.byId("dojox_mobile_ListItem_0");
									if(ListItem_0Label){
										var lab = getLabelfromWid(ListItem_0Label,0,listItem_0TestStr.length); 
										doh.is(lab, listItem_0TestStr);
									}
									var ListItem_1Label = registry.byId("dojox_mobile_ListItem_1");
									if(ListItem_1Label){
										doh.is(getLabelfromWid(ListItem_1Label,0,listItem_1TestStr.length), listItem_1TestStr);
									}
									var shiptostreetInput1Text = registry.byId("shiptostreetInput1");
									if(shiptostreetInput1Text){
										doh.is(shiptostreetInput1Text.value,"123 Valley Rd");
									}
									return dfd.callback(true);
								}, 500);
								return dfd;
							}
						}, {
							// Test first transition
							name : "transition-test-1",
							runTest : function() {
								var dfd = new doh.Deferred();
								setTimeout(function() {
									var liWidget = registry.byId("dojox_mobile_ListItem_1");
									var ev = new TransitionEvent(liWidget.domNode, liWidget.params);
									MQ3ColApp.children["MQ3ColApp_navLeft"].mainOption1Clicked(ev);
									//ev.dispatch()
									return dfd.callback(true);
								}, 500);
							}
						}, {
							// Test layout data 1
							name : "layout-data-test-1",
							runTest : function() {
								var dfd = new doh.Deferred();
								setTimeout(function() {
									var d = registry.byId("dojox_mobile_EdgeToEdgeCategory_0");
									if(d){
										doh.is("MainOption1 selected", d.domNode.innerHTML, "dojox_mobile_EdgeToEdgeCategory_0 should be set");
									}
									doh.t(MQ3ColApp.children["MQ3ColApp_navLeft"], "MQ3ColApp_navLeft viewShowing should be true");
									return dfd.callback(true);
								}, 1000);
								return dfd;
							}
						}, {
							// Test back transition
							name : "transition-back-1",
							runTest : function() {
								var dfd = new doh.Deferred();
								if(history){
									history.back();
									setTimeout(function() {
										doh.t(MQ3ColApp.children["MQ3ColApp_navLeft"], "MQ3ColApp_navLeft viewShowing should be true");
										var d = registry.byId("dojox_mobile_EdgeToEdgeCategory_0");
										if(d){
											doh.is("None selected", d.domNode.innerHTML, "dojox_mobile_EdgeToEdgeCategory_0 should be None selected");
										}
										return dfd.callback(true);
									}, 500);
								}
							}
						}]);
						doh.run();
					}
				}));
			});
		</script>
	</head>
	<body>
	</body>
</html>
